package com.yf1706.service;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import com.yf1706.bean.CheckCalendarAffair;
import com.yf1706.dao.jpa.ICheckAffairCategoryJDAO;
import com.yf1706.dao.jpa.ICheckCalendarAffairJDAO;
import com.yf1706.dao.jpa.IHolidayKindJDAO;
import com.yf1706.dao.mybatis.ICheckCalendarAffairMDAO;
import com.yf1706.vo.CheckCalendarAffairVO;
@Service
@Transactional(rollbackFor=Exception.class)
public class CheckCalendarAffairService {
	@Autowired
	private	ICheckCalendarAffairMDAO   ccaMDao;
	@Autowired
	private ICheckCalendarAffairJDAO  ccaJDao;
	@Autowired
	private IHolidayKindJDAO  hkJdao;
	@Autowired
	private ICheckAffairCategoryJDAO  cacJdao;
	public List<CheckCalendarAffair> getCalendarAffairList(){
		return ccaMDao.queryCalendarAffair();
	}
	//新增行政日历
	public void addcalendarAffair(CheckCalendarAffairVO ccavo) {
		CheckCalendarAffair cca=new CheckCalendarAffair();
		cca.setAffairBegintime(ccavo.getAffairBegintime());
		cca.setAffairEndtime(ccavo.getAffairEndtime());
		cca.setTheam(ccavo.getTheam());
		cca.setRemark(ccavo.getRemark());
		cca.setCheckHolidayKind(hkJdao.findByholidayId(ccavo.getHolidayId()));
		cca.setCheckAffariCategory(cacJdao.findByaffairId(ccavo.getAffairId()));
		ccaJDao.save(cca);
	}
	//修改行政事务
	public void updatecalendarAffair(CheckCalendarAffairVO ccavo) {
		CheckCalendarAffair cca1=new CheckCalendarAffair();
		cca1.setCalendarId(ccavo.getCalendarId());
		cca1.setAffairBegintime(ccavo.getAffairBegintime());
		cca1.setAffairEndtime(ccavo.getAffairEndtime());
		cca1.setTheam(ccavo.getTheam());
		cca1.setRemark(ccavo.getRemark());
		cca1.setCheckHolidayKind(hkJdao.findByholidayId(ccavo.getHolidayId()));
		cca1.setCheckAffariCategory(cacJdao.findByaffairId(ccavo.getAffairId()));
		ccaJDao.save(cca1);
	}
	//条件模糊查询
	public List<CheckCalendarAffair> serchcalendars(String begin,String end,String affairName){
		return ccaMDao.queryCalendarAffairs(begin,end,affairName);
	}
	//根据id删除
	public void deletecalendarAffair(int intValue) {
		ccaJDao.deleteById(intValue);		
	}
	
	
}
